
var vue=new Vue({
    el: "#app",
    data:{
    title:"MOMO登录",
    isShowRoles1:false,
    isShowRoles2:false,
    user:{
         account: "123456",
         password: "111111"
    }


    },
    created:{

    },
    methods:{
    //登录
    toLogin:function(){
        if (!(this.isShowRoles1&&this.isShowRoles2)) {
            axios.post("/logined", this.user).then(function (res) {

                if (res.data == "success") {
                    window.location.href = "/index";
                } else {
                    alert("账户或密码不正确");
                }
            })
        }else{
            alert("请输入用户名或密码");
        }
    },
    //处理表单校验
    validateForm1(){

        if (!this.user.account){
            this.isShowRoles1=true;
            document.getElementById('phone').classList.add('container_error')
        }else{
            this.isShowRoles1=false;
            document.getElementById('phone').classList.remove('container_error')
        }

    },
    validateForm2(){
            if (!this.user.password){

                this.isShowRoles2=true;
                document.getElementById('pwd').classList.add('container_error')
            }else{
                this.isShowRoles2=false;
                document.getElementById('pwd').classList.remove('container_error')
            }
        }
}

})



